/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Contact_panel.java
 *
 * Created on 22-05-2009, 21:24:27
 */

package VIEW;

import CONTROLLER.Controller;
import java.util.Observable;
import java.util.Observer;
import javax.swing.DefaultListModel;

/**
 *
 * @author Irene
 */
public class Contact_panel extends javax.swing.JPanel implements Observer {
   private Controller ctrl;

    /** Creates new form Contact_panel
     * 
     * @param ctrl
     */
    public Contact_panel(Controller ctrl) {
        this.ctrl = ctrl;
        initComponents();
        ctrl.addObserver(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        name = new javax.swing.JLabel();
        textName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textPhone = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        textAddress = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        TextEmail = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        textNote = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        familyButton = new javax.swing.JButton();
        friendsButton = new javax.swing.JButton();
        workButton = new javax.swing.JButton();
        OtherButton = new javax.swing.JButton();
        ClearButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listFamily = new javax.swing.JList();
        jScrollPane3 = new javax.swing.JScrollPane();
        listWork = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        listGym = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        listOther = new javax.swing.JList();
        labelFamily = new javax.swing.JLabel();
        labelFriends = new javax.swing.JLabel();
        labelWork = new javax.swing.JLabel();
        labelGym = new javax.swing.JLabel();
        labelOther = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        listFriends = new javax.swing.JList();
        deleteFamily = new javax.swing.JButton();
        DeleteFriend = new javax.swing.JButton();
        deleteOther = new javax.swing.JButton();
        deleteGym = new javax.swing.JButton();
        DeleteWork = new javax.swing.JButton();
        labelOther1 = new javax.swing.JLabel();
        gymButton = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Contacts"));

        name.setText("Name:");

        jLabel2.setText("Phonenumber:");

        jLabel3.setText("Address:");

        textAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textAddressActionPerformed(evt);
            }
        });

        jLabel4.setText("email:");

        jLabel5.setText("Note:");

        textNote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textNoteActionPerformed(evt);
            }
        });

        jLabel6.setText("Add to:");

        familyButton.setText("Family");
        familyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                familyButtonActionPerformed(evt);
            }
        });

        friendsButton.setText("Friends");
        friendsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                friendsButtonActionPerformed(evt);
            }
        });

        workButton.setText("Work");
        workButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                workButtonActionPerformed(evt);
            }
        });

        OtherButton.setText("Other");
        OtherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OtherButtonActionPerformed(evt);
            }
        });

        ClearButton.setText("Clear ");
        ClearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ClearButtonActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Groups"));

        listFamily.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(listFamily);

        jScrollPane3.setViewportView(listWork);

        jScrollPane4.setViewportView(listGym);

        jScrollPane5.setViewportView(listOther);

        labelFamily.setText("Family");

        labelFriends.setText("Friends");

        labelWork.setText("Work");

        labelGym.setText("Gym");

        labelOther.setText("Other");

        jScrollPane2.setViewportView(listFriends);

        deleteFamily.setText("Delete Family Contact");
        deleteFamily.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteFamilyActionPerformed(evt);
            }
        });

        DeleteFriend.setText("Delete Friend Contact");
        DeleteFriend.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteFriendActionPerformed(evt);
            }
        });

        deleteOther.setText("Delete Other Contact");
        deleteOther.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteOtherActionPerformed(evt);
            }
        });

        deleteGym.setText("Delete Gym Contact");
        deleteGym.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteGymActionPerformed(evt);
            }
        });

        DeleteWork.setText("Delete Work Contact");
        DeleteWork.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteWorkActionPerformed(evt);
            }
        });

        labelOther1.setText("Work");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(84, 84, 84)
                .addComponent(labelOther1)
                .addGap(164, 164, 164)
                .addComponent(labelGym)
                .addContainerGap(247, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(87, 87, 87)
                        .addComponent(labelFamily))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(118, 118, 118)
                        .addComponent(labelWork))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(DeleteWork)
                                .addGap(18, 18, 18)
                                .addComponent(deleteGym))
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(79, 79, 79)
                                .addComponent(labelFriends))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteFamily)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(DeleteFriend))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(82, 82, 82)
                        .addComponent(deleteOther)))
                .addGap(183, 183, 183))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(80, 80, 80)
                .addComponent(labelOther)
                .addContainerGap(433, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelFamily)
                    .addComponent(labelFriends))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(labelWork))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(labelOther1)
                            .addComponent(labelGym))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGap(11, 11, 11)
                .addComponent(labelOther)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(deleteFamily)
                            .addComponent(DeleteFriend))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(DeleteWork)
                            .addComponent(deleteGym))
                        .addGap(18, 18, 18)
                        .addComponent(deleteOther))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(140, 140, 140))
        );

        gymButton.setText("Gym");
        gymButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gymButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(ClearButton)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(name)
                                        .addGap(32, 32, 32))
                                    .addComponent(jLabel2)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel3)
                                            .addComponent(jLabel5))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(textName, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                    .addComponent(textPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                    .addComponent(textAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                    .addComponent(TextEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                    .addComponent(textNote, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(131, 131, 131)
                        .addComponent(OtherButton)
                        .addGap(67, 67, 67))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(familyButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(friendsButton)
                        .addGap(18, 18, 18)
                        .addComponent(workButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22)
                        .addComponent(gymButton, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(143, 143, 143)
                        .addComponent(jLabel6)
                        .addGap(80, 80, 80)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(name))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addGap(27, 27, 27)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TextEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(28, 28, 28)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textNote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ClearButton)
                        .addGap(19, 19, 19)
                        .addComponent(jLabel6)
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(familyButton)
                            .addComponent(friendsButton)
                            .addComponent(workButton)
                            .addComponent(gymButton))
                        .addGap(33, 33, 33)
                        .addComponent(OtherButton)))
                .addGap(31, 31, 31))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(46, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 598, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void textAddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textAddressActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textAddressActionPerformed

    private void textNoteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textNoteActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_textNoteActionPerformed

    private void familyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_familyButtonActionPerformed
        ctrl.addFamily(textName.getText(), textPhone.getText(), textAddress.getText(), TextEmail.getText(), textNote.getText());
}//GEN-LAST:event_familyButtonActionPerformed

    private void friendsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_friendsButtonActionPerformed
        ctrl.addFriend(textName.getText(), textPhone.getText(), textAddress.getText(), TextEmail.getText(), textNote.getText());
}//GEN-LAST:event_friendsButtonActionPerformed

    private void workButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workButtonActionPerformed
        ctrl.addWork(textName.getText(), textPhone.getText(), textAddress.getText(), TextEmail.getText(), textNote.getText());
}//GEN-LAST:event_workButtonActionPerformed

    private void gymButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gymButtonActionPerformed
        ctrl.addGym(textName.getText(), textPhone.getText(), textAddress.getText(), TextEmail.getText(), textNote.getText());        // TODO add your handling code here:
}//GEN-LAST:event_gymButtonActionPerformed

    private void OtherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OtherButtonActionPerformed
        ctrl.addOther(textName.getText(), textPhone.getText(), textAddress.getText(), TextEmail.getText(), textNote.getText());        // TODO add your handling code here:
}//GEN-LAST:event_OtherButtonActionPerformed

    private void ClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearButtonActionPerformed
        textName.setText("");
        textPhone.setText("");
        textAddress.setText("");
        TextEmail.setText("");
        textNote.setText("");
    }//GEN-LAST:event_ClearButtonActionPerformed

    private void deleteFamilyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteFamilyActionPerformed
     String s = (String) listFamily.getSelectedValue();
     ctrl.removeFamily(s);
}//GEN-LAST:event_deleteFamilyActionPerformed

    private void DeleteFriendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteFriendActionPerformed
    String s = (String) listFriends.getSelectedValue();
    ctrl.removeFriend(s);
}//GEN-LAST:event_DeleteFriendActionPerformed

    private void DeleteWorkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteWorkActionPerformed
     String s = (String) listWork.getSelectedValue();
     ctrl.removeWork(s);
    }//GEN-LAST:event_DeleteWorkActionPerformed

    private void deleteGymActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteGymActionPerformed
        String s = (String) listGym.getSelectedValue();
        ctrl.removeGym(s);
    }//GEN-LAST:event_deleteGymActionPerformed

    private void deleteOtherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteOtherActionPerformed
        String s = (String) listOther.getSelectedValue();
        ctrl.removeOther(s);
    }//GEN-LAST:event_deleteOtherActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ClearButton;
    private javax.swing.JButton DeleteFriend;
    private javax.swing.JButton DeleteWork;
    private javax.swing.JButton OtherButton;
    private javax.swing.JTextField TextEmail;
    private javax.swing.JButton deleteFamily;
    private javax.swing.JButton deleteGym;
    private javax.swing.JButton deleteOther;
    private javax.swing.JButton familyButton;
    private javax.swing.JButton friendsButton;
    private javax.swing.JButton gymButton;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JLabel labelFamily;
    private javax.swing.JLabel labelFriends;
    private javax.swing.JLabel labelGym;
    private javax.swing.JLabel labelOther;
    private javax.swing.JLabel labelOther1;
    private javax.swing.JLabel labelWork;
    private javax.swing.JList listFamily;
    private javax.swing.JList listFriends;
    private javax.swing.JList listGym;
    private javax.swing.JList listOther;
    private javax.swing.JList listWork;
    private javax.swing.JLabel name;
    private javax.swing.JTextField textAddress;
    private javax.swing.JTextField textName;
    private javax.swing.JTextField textNote;
    private javax.swing.JTextField textPhone;
    private javax.swing.JButton workButton;
    // End of variables declaration//GEN-END:variables

     public void update(Observable o, Object arg) {
              updateContactList();
        System.out.println("den virker");
    }
public void updateContactList(){
    DefaultListModel list = ctrl.getFamilyList();
    listFamily.setModel(list);
    DefaultListModel frList = ctrl.getFriendList();
    listFriends.setModel(frList);
    DefaultListModel gList = ctrl.getGymList();
    listGym.setModel(gList);
    DefaultListModel wList = ctrl.getWorkList();
    listWork.setModel(wList);
    DefaultListModel oList = ctrl.getOtherList();
    listOther.setModel(oList);
    repaint();
}
}
